package de.playmee.views;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class SimpleGalleryAdapter extends BaseAdapter {

	private Context context;
	private List<Integer> imageIds;
	private final int imageSize;
	
	public SimpleGalleryAdapter(Context context, List<Integer> imageIds, int imageSize) {
		this.context = context;
		this.imageIds = imageIds;
		this.imageSize = imageSize;
	}

	@Override
	public int getCount() {
		return imageIds.size();
	}

	@Override
	public Object getItem(int position) {
		return position; // not needed
	}

	@Override
	public long getItemId(int position) {
		return position; // not needed
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView = new ImageView(context);
		imageView.setImageResource(imageIds.get(position));
		imageView.setLayoutParams(new Gallery.LayoutParams(imageSize, imageSize));
		imageView.setScaleType(ImageView.ScaleType.FIT_XY);
		imageView.setPadding(5, 5, 5, 5);
		return imageView;
	}
}
